﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StyleMVVM.Configuration
{
	public static class IConfigurationServiceExtensions
	{
		public static async Task<T> GetValue<T>(this IConfigurationService service, string name)
		{
			return (T)await service.GetValue(name, typeof(T));
		}

		public static async Task<T> GetValue<T>(this IConfigurationService service, string name, T defaultValue)
		{
			return (T)await service.GetValue(name, typeof(T), defaultValue);
		}

		public static async Task<T> GetUserValue<T>(this IConfigurationService service, string userName, string name)
		{
			return (T)await service.GetUserValue(userName, name, typeof(T));
		}

		public static async Task<T> GetUserValue<T>(this IConfigurationService service,
		                                            string userName,
		                                            string name,
		                                            T defaultValue)
		{
			return (T)await service.GetUserValue(userName, name, typeof(T), defaultValue);
		}
	}
}